// (c) 2011 Greg Courville <Greg_Courville@GregLabs.com>

/* This file is part of GLExPIB.

   GLExPIB is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   GLExPIB is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GLExPIB.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <stdint.h>

#define GLEXPIB_ERR_PERM 1
#define GLEXPIB_ERR_TIMEOUT 2
#define GLEXPIB_ERR_NODEV 3
#define GLEXPIB_ERR_NDAC 4
#define GLEXPIB_ERR_NOMEM 5

//TODO: Add inline docs for public functions


typedef struct glexpib_state* glexpib_context;

int glexpib_init(glexpib_context *c, uint16_t basePort, uint8_t talker);
void glexpib_quit(glexpib_context c);
int glexpib_writeString(glexpib_context c, uint8_t addr, char *data, size_t len);
int glexpib_readString(glexpib_context c, uint8_t addr, char *data, size_t *len, size_t max);
void glexpib_setReadTimeout(glexpib_context c, uint32_t timeout);
void glexpib_setBusTimeout(glexpib_context c, uint32_t timeout);
const char *glexpib_strerror(int err);
